# -*- coding: utf-8 -*-
# @Time    : 2022/5/24 11:17
# @Author  : yangqing
# @Email   : 1292504517@qq.com
# @File    : test_qt_gwc.py
# @Software: PyCharm
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from page.page_base import BasePage
'''购物车page'''
class ShoppingCartS(BasePage):
    # def __init__(self,driver):
    #     self.driver = driver

        # 找到购物车，购买数量输入框(2page)
    ele_goods_input_num_locator = (By.XPATH, '/html/body/div[7]/div[1]/form/table[1]/tbody/tr[2]/td[5]/input')
        # 找到更新按钮
    ele_update_locator = (By.NAME, 'submit')
        # 找到结算中心
    ele_submit_btn_locator = (By.XPATH, '/html/body/div[7]/div[1]/table/tbody/tr/td[2]/a/img')
        # 找到继续购物的按钮
    ele_go_btn_locator = (By.XPATH, '/html/body/div[7]/div[1]/table/tbody/tr/td[1]/a/img')


    # 点击购物车购买数量输入框
    def goods_input_cilck(self):
        self.driver.find_element(*self.ele_goods_input_num_locator).click()
        sleep(2)
    # 清理购物车购买数量输入框
    def goods_input_clear(self):
        self.driver.find_element(*self.ele_goods_input_num_locator).clear()
        sleep(2)
    # 输入修改数量
    def goods_input(self):
        self.driver.find_element(*self.ele_goods_input_num_locator).send_keys(2)
        sleep(2)

    # 找到更新按钮 点击
    def update(self):
        self.driver.find_element(*self.ele_update_locator).click()
        sleep(5)

    # 点击结算中心
    def submit_btn(self):
        self.driver.find_element(*self.ele_submit_btn_locator).click()
        sleep(2)

    # 点击继续购物按钮
    def go_btn(self):
        self.driver.find_element(*self.ele_go_btn_locator).click()
        sleep(2)

    # 购物车购买数量输入框
    def goods_input_num(self):
        self.goods_input_cilck()
        self.goods_input_clear()
        self.goods_input()

